import axios from "../utils/Request"
import {Dispatch,} from "redux"
import {DataItem} from "../utils/index"

export let get_list = () =>{
  return async (dispatch:Dispatch)=>{
    let {data,status} = await axios.get("/api/list")
    status === 200 && dispatch({
      type: 'GET_LIST',
      payload: data.list
    })
  }
}

export let add_list = () =>{
  return async (dispatch:Dispatch)=>{
    let {data,status} = await axios.get("/api/addlist")
    // console.log(data);
     status === 200 && dispatch({
      type: 'ADD_LIST',
      payload: data.children
    })
  }
}

export let check_children_Data = (v:number)=>{
  return {
    type: 'CHECK_CHILDREN_DATA',
    payload: v
  }
}
export let get_details_data = (id:string)=>{
  return  {
    type: 'GET_DETAILS_DATA',
    payload: id
  }
  
}

export let show_Like = () => {
  return {
    type: 'SHOW_LIKE',
  }
}

export let add_shopcar_data = (item:DataItem) => {
  return {
    type: 'ADD_SHOPCAR_DATA',
    payload: item
  }
}

export let del_shopcar_data = (item:DataItem) => {  
  return {
    type: 'DELETE_SHOPCAR_DATA',
    payload: item
  }
}

export let add_shopcar_count =(item:DataItem) => {
  return {
    type: 'ADD_SHOPCAR_COUNT',
    payload: item
  }
}

export let del_shopcar_count = (item:DataItem) => {  
  return {
    type: 'DELETE_SHOPCAR_COUNT',
    payload: item
  }
}

export let show_shopcar_data  = (item:DataItem) => {
  return {
    type: 'SHOW_SHOPIFY_DATA',
    payload: item
  }
}

export let all_check_shopcar = (e:boolean) => {  
  return {
    type: 'ALL_CHECK_SHOPIFY',
    payload: e
  }
}